//
//  InvestRecordTableViewCell.m
//  Kjs-iOS
//
//  Created by 江伟 on 16/7/5.
//  Copyright © 2016年 jmhz. All rights reserved.
//

#import "CommonUtil.h"
#import "InvestRecordTableViewCell.h"

@interface InvestRecordTableViewCell ()
@property (nonatomic,strong) NSString *orderId;

@property (nonatomic,strong) IBOutlet UILabel *purchaseDateLab;
@property (nonatomic,strong) IBOutlet UILabel *itemNameLab;
@property (nonatomic,assign) IBOutlet UILabel *gdAnnualizedBenefitRateLab;
@property (nonatomic,strong) IBOutlet UILabel *interestDaysLab;
@property (nonatomic,strong) IBOutlet UILabel *gdBenefitModeLab;
@property (nonatomic,strong) IBOutlet UILabel *statusLab;
@property (nonatomic,strong) IBOutlet UILabel *totalPriceLab;
@property (nonatomic,strong) IBOutlet UILabel *orderIdLab;

@end

@implementation InvestRecordTableViewCell

- (void)awakeFromNib {
    // Initialization code
    self.endTransferBtn.layer.cornerRadius = 45/2;
    self.endTransferBtn.layer.masksToBounds = YES;
    self.endTransferBtn.titleLabel.numberOfLines = 0;
    [self sendSubviewToBack:self.contentView];
    self.totalPriceLab.adjustsFontSizeToFitWidth = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)setInvestRecord:(InvestRecord *)investRecord
{
  
    NSLog(@"传进来的investRecord＝%@",investRecord);
    self.itemNameLab.text = investRecord.itemName;
    self.gdAnnualizedBenefitRateLab.text = [NSString stringWithFormat:@"%.2lf％",investRecord.gdAnnualizedBenefitRate*100];
    self.interestDaysLab.text = [NSString stringWithFormat:@"%@天",investRecord.interestDays];
    self.gdBenefitModeLab.text = [CommonUtil getGdBenefitModeStrWithStrMode:investRecord.gdBenefitMode];
    self.orderIdLab.text = investRecord.orderId;
    self.statusLab.text = [CommonUtil getOrderStatusStrWithMode:investRecord.status];
    self.purchaseDateLab.text =  [[investRecord.purchaseDate componentsSeparatedByString:@"."] firstObject];
    float investMoneyFloat = [investRecord.totalPrice floatValue];
    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
    formatter.numberStyle = NSNumberFormatterDecimalStyle;
    NSString *investMoneyStr = [formatter stringFromNumber:[NSNumber numberWithFloat:investMoneyFloat]];
    self.totalPriceLab.text = [NSString stringWithFormat:@"¥%@",investMoneyStr];
    if ([investRecord.status isEqualToString:@"needvoucher"]) {
        [self.endTransferBtn setHidden:NO];
        [self.endTransferBtn setTitle:@"已完成\n  转账" forState:UIControlStateNormal];
    }else if ([investRecord.status isEqualToString:@"unconfirmed"]){
        [self.endTransferBtn setHidden:NO];
        [self.endTransferBtn setTitle:@"已上传\n  凭证" forState:UIControlStateNormal];
    }
    else{
        [self.endTransferBtn setHidden:YES];
    }
    self.orderId = investRecord.orderId;
}

@end
